package com.chuangke.common.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * Map<String,Object> map = MapBuilder.of(new HashMap<String,
 * Object>()).put("floorLimit", new BigDecimal(0.0)).put("upLimt", new
 * BigDecimal(5000.0)) .put("name", "五千以下").build(); 
 * 
 * Map<String,Object> map =
 * MapBuilder.<String, Object>of().put("floorLimit", new
 * BigDecimal(0.0)).put("upLimt", new BigDecimal(5000.0)) .put("name",
 * "五千以下").build();
 * 
 * @author Administrator
 *
 * @param <K>
 * @param <V>
 */
public class MapBuilder<K, V> {

	private final Map<K, V> map;

	public MapBuilder() {
		this.map = new HashMap<>();
	}

	public MapBuilder(Map<K, V> map) {
		this.map = map;
	}

	public MapBuilder<K, V> put(K key, V value) {
		this.map.put(key, value);
		return this;
	}

	public Map<K, V> build() {
		return this.map;
	}

	public static <K, V> MapBuilder<K, V> of() {
		return new MapBuilder<>();
	}

	public static <K, V> MapBuilder<K, V> of(Map<K, V> map) {
		return new MapBuilder<>(map);
	}
}
